//
//  AppDelegate.m
//  BuDeJie19
//
//  Created by hjj on 2016/12/3.
//  Copyright © 2016年 hjjuny. All rights reserved.
//

#import "AppDelegate.h"
#import "XMGTabBarController.h"
#import "XMGADViewController.h"
#import <SDImageCache.h>
#import "XMGStatusWindow.h"


/*
    点击状态栏功能，失效
    
    系统通过一个属性，来控制点击状态栏是否回到顶部
 
    scrollToTop:条件，一个屏幕只能有有一个scorllView的scrollToTop = YES
 
 */

/*
    状态栏也是一个窗口
 
    点击状态栏，回到顶部 (系统自带就有)
    1.实现点击状态栏，回到顶部。
    1.1 监听状态栏点击 pass
 
    1.1 往窗口上添加一个View,挡住状态栏 pass
 
    1.1 创建状态栏窗口，挡住状态栏
 
    1.2 设置tableView偏移量为-99
 
 */
@interface AppDelegate ()
@property (nonatomic, strong) UIWindow *statusWindow;
@end

@implementation AppDelegate

// 程序启动完成的时候，调用
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    // 1.创建窗口（OpenGL）
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    
    // 2.创建窗口根控制器，并且设置窗口根控制器
    // 窗口在显示的时候，把窗口根控制器的View添加窗口上
#warning TODO: online change 上线记得改
    XMGTabBarController *tabBarVc = [[XMGTabBarController alloc] init];
//    XMGADViewController *adVc = [[XMGADViewController alloc] init];
    self.window.rootViewController = tabBarVc;
    
    // 3.显示窗口
    [self.window makeKeyAndVisible];
    
    application.statusBarHidden = NO;
    
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
{
    // 1.清空图片缓存，SDWebImage
    [[SDImageCache sharedImageCache] clearMemory];
    
    // 2.NSCache
    
}

@end
